package lumis.portal.channel.serialization;

import lumis.portal.css.serialization.CssSerializableConfig;
import lumis.portal.group.serialization.GroupSerializableConfig;
import lumis.portal.serialization.Dependency;
import lumis.portal.serviceinterface.style.serialization.ServiceInterfaceStyleSerializableConfig;
import lumis.portal.stability.StableMinor;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Serializable value object for Channel structure root properties
 *
 * @version $Revision: 13082 $ $Date: 2011-05-27 16:03:12 -0300 (Fri, 27 May 2011) $
 * @since 4.0.7
 */
@StableMinor(version = "6.0", sinceVersion = "4.0")
public class ChannelSerializableRootConfig
{
	public static final String SERIALIZATION_VERSION = "5.7.0.0";
	
	private String version;
	private ChannelSerializableConfig channel;
	private List<ServiceInterfaceStyleSerializableConfig> serviceInterfaceStyles = new ArrayList<ServiceInterfaceStyleSerializableConfig>();
	private List<CssSerializableConfig> csss = new ArrayList<CssSerializableConfig>(); 
	private int channelCount;
	private List<Dependency> externalDependencies = new ArrayList<Dependency>();
	private Set<GroupSerializableConfig> globalGroups = new HashSet<GroupSerializableConfig>();
	private boolean shallowSerialization = false;
	
	public ChannelSerializableConfig getChannel()
	{
		return channel;
	}
	public void setChannel(ChannelSerializableConfig channel)
	{
		this.channel = channel;
	}
	public String getVersion()
	{
		return version;
	}
	public void setVersion(String version)
	{
		this.version = version;
	}
	public List<ServiceInterfaceStyleSerializableConfig> getServiceInterfaceStyles()
	{
		return serviceInterfaceStyles;
	}
	public void setServiceInterfaceStyles(List<ServiceInterfaceStyleSerializableConfig> serviceInterfaceStyles)
	{
		this.serviceInterfaceStyles = serviceInterfaceStyles;
	}
	public List<CssSerializableConfig> getCsss()
	{
		return csss;
	}
	public void setCsss(List<CssSerializableConfig> csss)
	{
		this.csss = csss;
	}
	public int getChannelCount()
	{
		return channelCount;
	}
	public void setChannelCount(int channelCount)
	{
		this.channelCount = channelCount;
	}
	public List<Dependency> getExternalDependencies()
	{
		return externalDependencies;
	}
	public void setExternalDependencies(List<Dependency> externalDependencies)
	{
		this.externalDependencies = externalDependencies;
	}
	private Object readResolve()
	{
		if (csss == null)
			csss = new ArrayList<CssSerializableConfig>();
		return this;
	}

	/**
	 * Returns the global groups for serializing.
	 * These global groups will be added to the destination when imported.
	 * 
	 * @return the global groups to be serialized.
	 * @since 4.2.1
	 */
	public Set<GroupSerializableConfig> getGlobalGroups()
	{
		return this.globalGroups;
	}

	/**
	 * Sets whether the serialization will serialize the structure recursively or not.
	 * When set to false all sub-channels are recursively serialized.  If true only the
	 * root channel and its pages, service instances, local groups, page templates, acls,
	 * and all the globally referenced css files, interface instance xsl files and global
	 * groups are exported.
	 * 
	 * @param shallowSerialization the shallow serialization value.
	 * @since 5.0.0
	 */
	public void setShallowSerialization(boolean shallowSerialization)
	{
		this.shallowSerialization = shallowSerialization;
	}
	
	/**
	 * Returns whether the serialization is recursive or not.  See {@link #setShallowSerialization(boolean)}
	 * for more details on recursion implications.
	 * 
	 * @return true when shallow serialization is set or false when serialization is recursive.
	 * @since 5.0.0
	 */
	public boolean isShallowSerialization()
	{
		return this.shallowSerialization;
	}
}
